package com.gears_software.sxdc.dccx.ui.view;

import android.content.Context;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.facebook.drawee.view.SimpleDraweeView;
import com.gears_software.sxdc.dccx.R;
import com.gears_software.sxdc.dccx.application.DCCXApplication;
import com.gears_software.sxdc.dccx.data.model.MyTripModel;

import org.androidannotations.annotations.App;
import org.androidannotations.annotations.EViewGroup;
import org.androidannotations.annotations.ViewById;

import java.text.SimpleDateFormat;

/**
 * Created by chezhenzhen on 2017/7/26.
 */

@EViewGroup(R.layout.item_view_mytrip)
public class MyTripListItemView extends LinearLayout {
    Context context;
    @App
    DCCXApplication app;
    @ViewById
    TextView txt_triptime_icon;
    @ViewById
    TextView txt_right_icon1;
    @ViewById
    TextView tv_who;
    @ViewById
    TextView txt_departtime;
    @ViewById
    TextView txt_start;
    @ViewById
    TextView txt_end;
    @ViewById
    TextView txt_state;

    public MyTripListItemView(Context context) {
        super(context);
        this.context = context;
    }

    public void bind(MyTripModel model) {
        txt_triptime_icon.setTypeface(app.iconfont);
        txt_right_icon1.setTypeface(app.iconfont);
        if (model != null) {
            if (model.getFlag() == 1) {
                tv_who.setText("车主");
                switch (model.getOrderstatus()) {
                    case 1:
                        txt_state.setText("预定中");
                        break;
                    case 2:
                        txt_state.setText("预定成功");
                        break;
                    case -1:
                        txt_state.setText("已取消");
                        break;
                    default:
                        txt_state.setVisibility(GONE);
                        break;
                }
            } else {
                tv_who.setText("乘客");
                switch (model.getOrderstatus()) {
                    case 1:
                        txt_state.setText("待司机确认");
                        break;
                    case 2:
                        txt_state.setText("预定成功");
                        break;
                    case -1:
                        txt_state.setText("已取消");
                        break;
                    default:
                        txt_state.setVisibility(GONE);
                        break;
                }
            }
            SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
            txt_departtime.setText(sf.format(model.getDeparttime()));
            txt_start.setText(model.getStartpoint());
            txt_end.setText(model.getEndpoint());
        }


    }
}
